package com.woniu.controller;

import com.woniu.entity.RbacMenu;
import com.woniu.entity.ResponseEntity;
import com.woniu.service.RbacMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/9/9 11:41
 */
@RestController
@RequestMapping("/rbacMenu")
public class RbacMenuController {
    @Autowired
    RbacMenuService rbacMenuService;

    @GetMapping("/")
    public ResponseEntity findAll() {
        return rbacMenuService.findAll();
    }

    @PutMapping("/")
    public ResponseEntity editOne(@RequestBody RbacMenu rbacMenu) {
        return rbacMenuService.editOne(rbacMenu);
    }

    //拖动菜单后更新后台数据
    @PutMapping("/{id}/{fid}")
    public ResponseEntity updateMenu(@PathVariable int id, @PathVariable Integer fid) {
        return rbacMenuService.updateMenu(id, fid);
    }

    //根据登录用户权限查询菜单
    @GetMapping("/{id}")
    public ResponseEntity showMenuByUserId(@PathVariable int id) {
        return rbacMenuService.showMenuByUserId(id);
    }

    //获取角色菜单的所有id
    @GetMapping("/getMenuId/{id}")
    public ResponseEntity getMenuIdUserId(@PathVariable int id) {
        return rbacMenuService.getMenuIdUserId(id);
    }
}
